Skip to content

feat(mock-ai): deterministic benchmark scenarios, strict session routing, and harness-bench runner - #7391

Open
M4n5ter wants to merge 4 commits into
mainfrom
bench/agent-harness
Open

M4n5ter wants to merge 4 commits into
mainfrom
bench/agent-harness

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 28, 2026

Copy link
Copy Markdown
Member

Summary

Upgrades maka-mock-ai into an ultra-realistic, receipt-driven multi-protocol AI provider simulator suitable for fair, high-concurrency cross-harness stress benchmarking, and adds a zero-dependency Node ESM runner under tools/harness-bench/.

tools/mock-ai

  • Scoped routing, strict identity & separated lifecycles (src/routing.rs, src/control.rs, src/proxy.rs):
    • Single-pass /s/<run>/<session>/... route parser covering HTTP, WebSocket upgrade, GET /v1/models/{id}, POST /v1/messages/count_tokens, POST /v1/responses/compact, and owner-scoped GET/DELETE /v1/responses/{id}.
    • Explicit SessionRegistry and identity resolver with conflict diagnostics; separated logical session / response lineage / stored-body lifecycles (deleting a parent mid-flight never loses an in-flight completed child; response body clones/drops happen outside locks).
    • RequestClassifier isolating Main / Side / Compact / Control (including OpenCode/Claude title side-calls and Codex native client summary requests, with positive and negative regression cases).
    • Proxy v2 canonical fingerprints (including response_format, text.format, anthropic-beta, query, lane), versioned cassette compatibility checks, and replay coverage for response GET/DELETE.
  • Deterministic semantic scenario engine & 10-harness tool binder (src/scenario/, src/schema_synth.rs):
    • Receipt-driven atomic revision state machine using lightweight PlanRecipe + RequestKey so 429/503/disconnect/HTTP↔WS retries replay the exact same decision with zero step skipping; supports out-of-order parallel receipts, client & native compaction checkpoints, and POST /admin/sessions/{id}/observations.
    • jsonschema + freeform grammar binding across Maka (direct & Code Mode exec(code)), Claude Code, Codex (custom apply_patch + nested namespace MCP), OpenCode v2, Pi 1.0, Pi-Durable, Dim (native edit(oldText/newText) + exec(command) & Shared MCP), DeepSeek Harness, ZCode, Kimi Code, and Shared MCP.
    • Unified 256 KiB synthesis budget covering defaults/strings with per-branch rollback on anyOf/oneOf.
  • Protocol fidelity & zero-waste streaming (src/protocol.rs, src/plan.rs, src/codec/, src/server/):
    • EncodedFrame tags FrameKind and semantic_bytes directly, removing hot-path TTFT JSON reparsing and redundant non-streaming chunk iteration.
    • Anthropic event: ping, signed thinking, is_error, disable_parallel_tool_use, pause_after_compaction; Chat stream_options.include_usage & dialect-gated reasoning_content; Responses sequence_number, independent content_index, nested namespace calls, and WS generate: false warmup returning empty response.completed.
  • Observability, fact-driven watchdog & pacing (src/watchdog.rs, src/metrics.rs, src/pacing.rs, src/ratelimit.rs, src/server/admin.rs):
    • Monotonic-ns AttemptSpan, dual-budget per-session rings, paginated /admin/sessions* export/finalize/reclaim, interval-union three-way attribution (mock_service_sum / outside_mock_wall / mock_union), Prometheus mixed-status label fix, generation-guarded reset/fault counters, and absolute decode deadlines.

tools/harness-bench

  • Zero-dependency Node ESM benchmark runner (preflight, run, calibrate, matrix) with 5 built-in scenarios (smoke-edit, concurrency-fanout, long-compaction, chaos-recovery, mcp-smoke-edit), workspace fixture verifier, stdio Shared MCP server with independent JSONL audit log, process-tree RSS/CPU monitor + SIGKILL durability injector, 16 isolated adapters (10 harnesses + ref-agent), and end-to-end tests.

Verification

  • cargo test -p maka-mock-ai --no-fail-fast: 99 passed (69 lib + 12 advanced_simulation + 13 protocol_conformance + 5 stress_and_scenarios)
  • cargo check -p maka-mock-ai --no-default-features, cargo clippy -p maka-mock-ai --all-targets -- -D warnings, cargo fmt -p maka-mock-ai -- --check: passed
  • Workspace consumers (maka-model, maka-agent-native, maka-eval, maka-cli --tests): checked clean
  • node --test tools/harness-bench/bench.test.mjs: 7/7 passed
  • node scripts/asf-license-headers.mjs check: passed
  • Live CLI smoke verified against maka-mock-ai on ref-agent, claude, codex-http, codex-ws, and dim (native + Shared MCP)

…routing, and harness-bench runner

Upgrade maka-mock-ai into a protocol-faithful, receipt-driven simulator for fair multi-harness stress benchmarking, and add a zero-dependency Node ESM benchmark runner under tools/harness-bench:

- Scoped routing & lineage (src/routing.rs, src/control.rs, src/proxy.rs):
  - Single-pass /s/<run>/<session>/... route parser across HTTP, WS, /models/{id}, /v1/messages/count_tokens, /v1/responses/compact, and owner-scoped GET/DELETE /v1/responses/{id}.
  - Explicit SessionRegistry, strict identity precedence with conflict diagnostics, side-channel/compaction classifier (Main / Side / Compact / Control), and separated session/lineage/stored-body lifecycles with lock-free drops.
  - Proxy v2 canonical request fingerprints (including response_format, text.format, anthropic-beta, query, lane) with versioned compatibility checks and replay for response GET/DELETE.
- Deterministic semantic scenario engine & cross-harness tool binder (src/scenario/, src/schema_synth.rs):
  - Receipt-driven atomic revision state machine with PlanRecipe/RequestKey idempotency across 429/503/disconnect/HTTP-WS retries, out-of-order parallel receipts, client & native compaction checkpoints, and runner observations via POST /admin/sessions/{id}/observations.
  - Schema-validated (jsonschema) and freeform grammar tool binding across Maka (direct & Code Mode), Claude Code, Codex (custom apply_patch + nested namespace MCP), OpenCode v2, Pi 1.0, Pi-Durable, Dim, DeepSeek Harness, ZCode, Kimi Code, and Shared MCP.
- Wire codec fidelity & zero-waste streaming (src/protocol.rs, src/plan.rs, src/codec/, src/server/):
  - EncodedFrame carries FrameKind + semantic_bytes (removing hot-path TTFT JSON reparsing and redundant non-streaming chunk iteration).
  - Anthropic ping/thinking+signature/is_error/disable_parallel_tool_use/pause_after_compaction, Chat stream_options.include_usage & dialect-gated reasoning_content, Responses sequence_number/content_index/namespace/WS generate:false warmup.
- Observability, fact-driven watchdog & pacing (src/watchdog.rs, src/metrics.rs, src/pacing.rs, src/ratelimit.rs, src/server/admin.rs):
  - Monotonic-ns AttemptSpan, dual-budget per-session rings, paginated /admin/sessions* export/finalize/reclaim, interval-union attribution (mock_service_sum / outside_mock_wall / mock_union), Prometheus status label fix, generation-guarded reset/faults, and absolute decode deadlines.
- Multi-harness benchmark runner (tools/harness-bench/):
  - Zero-dependency Node ESM CLI (preflight, run, calibrate, matrix), 5 built-in scenarios, isolated workspace fixture verifier, stdio Shared MCP server with independent JSONL audit log, process-tree RSS/CPU monitor with SIGKILL injection, 16 isolated adapters (10 harnesses + ref-agent), and end-to-end tests.
@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant